<!doctype html>
<html>

<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>API信息编辑</title>
<link rel="stylesheet" href="../css/edit.css">
<link rel="stylesheet" href="../css/main.css">
<link rel="stylesheet" href="../css/bootstrap.css" type="text/css" media="all">
<script type="text/javascript" src="../lib/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="../lib/jquery-ui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="../lib/ajax/ajaxfileupload.js"></script>
<script type="text/javascript" src="../utility/utility.js"></script>
<script type="text/javascript" src="../utility/component.js"></script>
<script type="text/javascript" src="js/api.js"></script>
</head>

<body>
	<div class="middle" style="padding: 50px; font-size: 30px">
		<span id="itemTitle"></span>
		<button class="btn" onclick="toPage('./index.html')" style="float: right; border: 2px solid #000000">返回主页</button>
	</div>
	<div style="background-color: #459df5; height: 40px;"></div>
	<div class="middle">
		<span id="infoout" style="color: red"></span>
	</div>
	<div class="middle border">
		<div>
			<table class="table table-bordered table-striped" style="width: 100%; margin-bottom: 0px">
				<tbody>
					<tr>
						<th style="width: 15%;">属性编辑</th>
						<th></th>
						<th style="width: 48px;"><span class="btn btn32 btn-staron"></span></th>
						<th style="width: 150px; text-align: right">保存修改&nbsp;&nbsp;&nbsp;<span class='btn-ok btn btn32 ripple'
							onclick="commit()"></span></th>
					</tr>
				</tbody>
			</table>
			<table class="table table-bordered table-striped" style="margin-bottom: 0px; width: 100%">
				<thead style="width: 100%" id="subofHolder">
					<tr>
						<th style="width: 15%;">标题</th>
						<td style="width: 35%"><input id="input_title" style="text-align: left; width: 100%"></td>
						<th style="width: 15%; vertical-align: middle">使用模型&nbsp;&nbsp;&nbsp;<span class='btn-refresh btn btn32 ripple'
							onclick="refreshModel()"></span></th>
						<td><select id="inputModel" class="form-control" style="width: 100%">
						</select></td>
					</tr>
				</thead>
			</table>
			<table class="table table-bordered table-striped" style="width: 100%">
				<tbody>
					<tr>
						<th style="width: 15%">API地址</th>
						<td style="text-align: left; vertical-align: middle" id="apiurl">http://127.0.0.1</td>
						<th style="width: 150px; text-align: right">设置API KEY&nbsp;&nbsp;&nbsp;<span class='btn-file btn btn32 ripple'
							onclick="editKey()"></span></th>
					</tr>
				</tbody>
			</table>
			<table class="table table-bordered table-striped" style="margin-bottom: 0px; width: 100%">
				<tbody>
					<tr>
						<th style="vertical-align: top; width: 100px">System Prompt</th>
						<td style="text-align: left; vertical-align: middle"><textarea id='input_prompt_sys'
								style="height: 60px; width: 100%; resize: vertical" placeholder='输入Prompt' onkeyup="promptChange(1)"></textarea> <span>当前系统Prompt字数</span>&nbsp;<span
							id="prompt_len1">0</span></td>
					</tr>
				</tbody>
			</table>
			<table class="table table-bordered table-striped" style="width: 100%">
				<tbody>
					<tr>
						<th style="text-align: left; vertical-align: top; width: 100px">User Prompt</th>
						<td style="text-align: left; vertical-align: middle"><textarea id='input_prompt_user'
								style="height: 200px; width: 100%; resize: vertical" placeholder='输入Prompt' onkeyup="promptChange(2)"></textarea> <span>当前用户Prompt模板字数</span>&nbsp;<span
							id="prompt_len2">0</span></td>
					</tr>
				</tbody>
			</table>
			<table class="table table-bordered table-striped" style="width: 100%">
				<thead>
					<tr>
						<th style="text-align: left; vertical-align: middle; width: 200px">API参数名称</th>
						<th style="text-align: left; vertical-align: middle; width: 200px">参数备注</th>
						<th style="text-align: left; vertical-align: middle; width: 200px">参数默认值 <a>(传参为空时生效)</a></th>
						<th style="text-align: left; vertical-align: middle">参数样例&nbsp;&nbsp; <a>(仅测试用，API调用时需要重新传参)</a>
						</th>
						<th style="text-align: center; width: 48px"><span class='btn-add btn btn32 ripple' onclick="addParam()"></span></th>
					</tr>
				</thead>
				<tbody id="paramHolder">
					<tr id="param0">
						<td style="text-align: left; vertical-align: middle"><input id="param_key0"
							style="text-align: left; width: 100%; height: 32px"></td>
						<td style="text-align: left; vertical-align: middle"><input id="param_title0"
							style="text-align: left; width: 100%; height: 32px"></td>
						<td style="text-align: left; vertical-align: middle"><input id="param_def0"
							style="text-align: left; width: 100%; height: 32px"></td>
						<td style="text-align: left; vertical-align: middle"><input id="param_value0"
							style="text-align: left; width: 100%; height: 32px"></td>
						<td style="text-align: center; width: 48px"><span class='btn-del btn btn32 ripple' onclick="delParam(0)"></span></td>
					</tr>
				</tbody>
			</table>
			<table class="table table-bordered table-striped" style="width: 100%">
				<thead>
					<tr>
						<th style="text-align: left; width: 150px; vertical-align: middle">API测试</th>
						<th style="text-align: center; width: 48px; vertical-align: middle"><span class='btn-up btn btn32 ripple'
							onclick="apiTest()"></span></th>
						<th style="text-align: left; width: 150px; vertical-align: middle">prompt测试</th>
						<th style="text-align: center; width: 48px; vertical-align: middle"><span class='btn-up btn btn32 ripple'
							onclick="promptTest()"></span></th>
						<td style="text-align: left; vertical-align: middle"><span id="output_info"></span></td>
						<th style="text-align: left; width: 110px; vertical-align: middle">保存测试结果</th>
						<td style="text-align: center; width: 48px; vertical-align: middle"><span class='btn-save btn btn32 ripple'
							onclick="saveResult()"></span></td>
						<td style="text-align: left; width: 140px; vertical-align: middle"><span id="save_info"></span></td>
						<th style="text-align: left; width: 150px; vertical-align: middle">查看保存的测试结果</th>
						<td style="text-align: center; width: 64px; vertical-align: middle" id="save_num"></td>
						<td style="text-align: center; width: 48px; vertical-align: middle"><span class='btn-history btn btn32 ripple'
							onclick="showHistory()"></span></td>
					</tr>
				</thead>
			</table>
		</div>
		<div>
			<label class="title">测试结果</label>
		</div>
		<div class="border" style='width: 100%;'>
			<pre id="output_test" style="text-align: left; width: 100%; height: 300px; white-space: pre-wrap; resize: vertical"></pre>
			<table class="table table-bordered table-striped" style="width: 100%; display: none">
				<thead>
					<tr>
						<th style="text-align: left; width: 150px; vertical-align: middle">保存测试结果</th>
						<th style="text-align: center; width: 48px; vertical-align: middle"><span class='btn-save btn btn32 ripple'
							onclick="saveResult()"></span></th>
						<td style="text-align: left; vertical-align: middle"><span id="save_info"></span></td>
					</tr>
					<tr>
						<th style="text-align: left; width: 150px; vertical-align: middle">查看保存的测试结果</th>
						<th style="text-align: center; width: 48px; vertical-align: middle"><span class='btn-history btn btn32 ripple'
							onclick="showHistory()"></span></th>
						<td style="text-align: left; vertical-align: middle"></td>
					</tr>
				</thead>
			</table>
		</div>
	</div>
	<div id="frameHolder"></div>
</body>